package com.foo.common.base.action;

import java.io.IOException;

import com.foo.common.base.pojo.DeviceInfoModel;
import com.foo.common.base.utils.FooUtils;
import com.foo.core.dict.model.DictModel;

public class TestAction extends FooGenericAction {

	private static final long serialVersionUID = 1L;

	@org.apache.struts2.convention.annotation.Action("/dict/testSave")
	public void testSave() throws IOException {

		DictModel dictModel = new DictModel();
		dictModel.setKey("200");
		dictModel.setValue("sichuan");
		System.out.println(fooGenericService.save(dictModel));
		FooUtils.printJsonSuccessMsg(response);
	}

	@org.apache.struts2.convention.annotation.Action("/dict/testLoad")
	public void testLoad() throws IOException {
		DictModel dictModel = (DictModel) fooGenericService.load(
				DictModel.class, "200");
		System.out.println(dictModel.getValue());
		FooUtils.printJsonSuccessMsg(response);
	}

	@org.apache.struts2.convention.annotation.Action("/dict/testLog")
	public void testLog() throws IOException {
		response.getWriter().write(fooGenericService.logSummary());
	}

	@org.apache.struts2.convention.annotation.Action("/test")
	public void test() throws Exception {
		Object t = fooGenericService.getObject(DeviceInfoModel.class,
				"select * from ITMS_DEVICE_STATIC");
		response.getWriter().write(t.toString());
	}
}
